package logic

import (
	"context"
	"home-lister/homerpc/homerpc"

	"home-lister/api/internal/svc"
	"home-lister/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type HomeDetailLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewHomeDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HomeDetailLogic {
	return &HomeDetailLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *HomeDetailLogic) HomeDetail(req *types.HomeDetailRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	detail, err := l.svcCtx.HomeRpc.HomeDetail(l.ctx, &homerpc.HomeDetailRequest{
		HomeId: int64(req.HomeId),
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}

	return &types.Response{
		Message: "获取详情成功",
		Code:    200,
		Data:    detail,
	}, nil

}
